<template>
	<view class="currentPage">
		<topCard :userInfo='userInfo'></topCard>
		<functionList :count="count" @changeInfo="confirm"></functionList>
		<buttonOperation @tapBtn='tapBtn' v-if="userInfo">
			退出登录
		</buttonOperation>
		<!-- 占位符 -->
		<view style="height: 100upx;width: 100%;"  v-if="userInfo">
			
		</view>
		<u-modal :show="show" :closeOnClickOverlay="true" :showCancelButton='true' :title="'提示'" @confirm='confirm'
			@cancel='cancel' :content="'是否退出登录？'" confirmColor="#157DFA"></u-modal>
			<m-tabbar native>
				<template v-slot:tabbar_index_1>
					<view class="custom_style">
						<view class="custom_style_icon"></view>
					</view>
				</template>
			</m-tabbar>
	</view>
</template>

<script>
	import functionList from '@/components/my/functionList.vue'
	import topCard from '@/components/my/topCard.vue'
	import buttonOperation from '@/components/common/buttonOperation.vue'
	import {
		myUnreadCount
	} from '@/request/api.js';
	export default {
		components: {
			functionList,
			topCard,
			buttonOperation
		},
		data() {
			return {
				isLogin: false,
				// userInfo:  {
				// 	avatar:'https://cdn.uviewui.com/uview/album/1.jpg',
				// 	nickname:'波比',
				// 	mobile:"18487301491"
				// },
				userInfo:null,
				show: false,
				count: 0
			}
		},
		onShareAppMessage() {
			return {
				title: '瑞能电力',
				path: '/pages/my/my',
		
			}
		},
		onShareTimeline: function() {
			return {
				title: '瑞能电力',
				path: '/pages/my/my',
			}
		},
		onLoad() {
			let userInfo = uni.getStorageSync('userInfo')
			this.userInfo = userInfo
			uni.$on('hasLogin', val => {
				if (val) this.isLogin = true
				let userInfo = uni.getStorageSync('userInfo')
				console.log(userInfo)
				this.userInfo = userInfo
			})
		},
		onShow() {
			this.myUnreadCountFnc()
		},
		methods: {
			async myUnreadCountFnc() {
				let res = await myUnreadCount()
				this.count = res.data
			},
			tapBtn() {
				this.show = true
			},
			confirm() {
				uni.removeStorageSync('token')
				uni.removeStorageSync('userInfo')
				this.show = false
				this.userInfo = null
			},
			cancel() {
				this.show = false
			}
		}
	}
</script>
<style>
	page {
		background-color: #fff;
		overflow: hidden;
	}
</style>
<style lang="scss" scoped>
	::v-deep  .u-popup__content{
		bottom: 80px;
	}
	.currentPage {
		// min-height: 100vh;
		background-color: #fff;
		
	}
	.custom_style{
	        color: #fff;
	        display: flex;
	        flex-direction: column;
	        align-items: center;
	        justify-content: center;
	        font-size: 24rpx;
	        &_icon{
	            // background-color: #15357A;
				background-image: url(../../static/tabble/tab2.png);
	            font-size: 65rpx;
	            width: 90rpx;
	            height: 90rpx;
	            border-radius: 100%;
	            display: flex;
				background-repeat: no-repeat;
				background-size: 100%;
	            justify-content: center;
	            align-items: center;
	            margin-top: -40rpx;
	        }
	    }
</style>
<style>
	.u-popup__content.data-v-3a231fda {
		margin-top: 360rpx;
		width: 90%;
		border-radius: 50rpx;
		    overflow: hidden;
	}
	 .u-tag--mini{
		height: 16px !important;
		font-size: 24rpx !important;
	}
</style>